import request from '@/utils/request'

const base_url = "acl/admin"

export function login(username, password) {
	return request({
		url: `${base_url}/login`,
		method: 'post',
		data: {
			username,
			password
		}
	})
}

export function getInfo() {
	return request({
		url: `${base_url}/info`,
		method: 'get',
	})
}

export function logout() {
	return request({
		url: `${base_url}/logout`,
		method: 'post'
	})
}

export function fetchList(params) {
	return request({
		url: `${base_url}/list`,
		method: 'get',
		params: params
	})
}

export function createAdmin(data) {
	return request({
		url: `${base_url}/register`,
		method: 'post',
		data: data
	})
}

export function updateAdmin(id, data) {
	return request({
		url: `${base_url}/update/${id}`,
		method: 'post',
		data: data
	})
}

export function updateStatus(id, params) {
	return request({
		url: `${base_url}/updateStatus/${id}`,
		method: 'post',
		params: params
	})
}

export function deleteAdmin(id) {
	return request({
		url: `${base_url}/delete/${id}`,
		method: 'post'
	})
}

export function getRoleByAdmin(id) {
	return request({
		url: `${base_url}/role/${id}`,
		method: 'get'
	})
}

export function allocRole(data) {
	return request({
		url: `${base_url}/role/update`,
		method: 'post',
		data: data
	})
}